package util

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

type Result struct {
	Data   gin.H
	Msg    string
	Status int
}

func Success(c *gin.Context, result *Result) {
	if len(result.Msg) <= 0 {
		result.Msg = "请求成功！"
	}
	c.JSON(http.StatusOK, gin.H{
		"msg":     result.Msg,
		"data":    result.Data,
		"success": true,
	})
}
func Error(c *gin.Context, result *Result) {
	if len(result.Msg) <= 0 {
		result.Msg = "请求失败！"
	}
	c.JSON(result.Status|http.StatusBadRequest, gin.H{
		"msg":     result.Msg,
		"data":    result.Data,
		"success": false,
	})
}
